package com.hptpd.questionnairesurvey.controller.wx;

import com.hptpd.questionnairesurvey.component.Result;
import com.hptpd.questionnairesurvey.controller.base.BaseController;
import com.hptpd.questionnairesurvey.service.IWeiXinApiService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * \* Created with IntelliJ IDEA.
 * \* Date: 2019/10/29
 * \*
 * \* Description:
 * \
 *
 * @author walter_long
 */
@RestController
@RequestMapping("/api/wx")
public class WxApiController extends BaseController {
    @Resource(name = "iWeiXinApiService")
    private IWeiXinApiService iWeiXinApiService;

    /**
     * 微信小程序获取openid
     * @param code String
     * @param secretCode String
     * @param appid String
     * @return Object
     */
    @RequestMapping(value = "/wxapi/openid", method = RequestMethod.GET)
    public Result getOpenid(
            @RequestParam(defaultValue = "") String code,
            @RequestParam(defaultValue = "") String secretCode,
            @RequestParam(defaultValue = "") String appid){
        return iWeiXinApiService.getOpenid(code, secretCode, appid);
    }
}
